#
for i in [1, 2, 3]:
    print(i)

li = iter([1, 2, 3])  # 转换为循环对象
li.__next__()

for i in iter([1, 2, 3]):
    print(i)


# 生成器
def gen():
    a = 100
    yield a
    a = 1000
    yield a
    yield 10000


for i in gen():
    print(i)


def gen():
    i = 0
    while i < 10:
        i += 1
        if i % 2 == 0:
            continue
        if i % 5 == 0:
            continue
        yield i


# 列表解析
L = [x ** 2 for x in range(10)]
L1 = [x ** 2 for x in range(10) if x % 2 == 0]
